import { TFlyGrowCulture } from "../../../Message/Db/Tables/TFlyGrowCulture";
import { CutDataUtil } from "../../common/tools/CutDataUtil";
import { CareerUtil } from "../view/common/util/CareerUtil";
import { WardrobeInfo } from "../model/WardrobeInfo";
import { WardrobeType } from "../view/wardrobe/WardrobeType";
import { ItemConfig } from "./ItemConfig";
import { WardrobeConfigInfo } from "./info/WardrobeConfigInfo";
import { ItemData } from "./info/ItemData";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TFlyExpUpgrade } from "../../../Message/Db/Tables/TFlyExpUpgrade";
type int = number;
//class WardrobeConfig
    
    export  class WardrobeConfig
    {
        constructor()
        {
            
            this._fashionArr = [];
            this._wingArr = [];
            this._fashionWeaponArr = [];
            this._footPrintArr = [];
            this._posBubbleArr = [];
            this._surroundArr = [];
            this._waistBeltArr = [];
            this._elfArr = [];
            this._suitArr = [];
            this._modelIdMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._fashionJewelAttriByLvDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._fashionJewelExpDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._fashionJewelPosDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._fashionJewelValueDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._flyLvToNeedExpDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._flyLvToGrowLvLimitDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._flyGrowToNeedExpDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._flyGrowToAddAttValueDic = new Map<any, any> /* flash.utils.Dictionary */();
            if (WardrobeConfig._instance != null) 
            {
                throw new Error("WardrobeConfig 单例");
            }
            this.init();
            return;
        }

        public getFlyLvNeddExp(arg1: int): int
        {
            return this._flyLvToNeedExpDic[arg1];
        }

        /* internal  */writeObjFlyGrow(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                loc1 = new TFlyGrowCulture();
                loc1.growLevel = loc3.growLevel;
                loc1.needGrowValue = loc3.needGrowValue;
                loc1.attribute1 = loc3.attribute1;
                loc1.attributeValue1 = loc3.attributeValue1;
                loc1.attribute2 = loc3.attribute2;
                loc1.attributeValue2 = loc3.attributeValue2;
                loc1.attribute3 = loc3.attribute3;
                loc1.attributeValue3 = loc3.attributeValue3;
                loc1.attribute4 = loc3.attribute4;
                loc1.attributeValue4 = loc3.attributeValue4;
                loc1.attribute5 = loc3.attribute5;
                loc1.attributeValue5 = loc3.attributeValue5;
                this._flyGrowToNeedExpDic[loc1.growLevel] = loc1.needGrowValue;
                this._flyGrowToAddAttValueDic[loc1.growLevel] = loc1;
            }
            return;
        }

        public getFlyGrowAtt(arg1: int): Array<any>
        {
            var loc8=0;
            var loc1=[];
            var loc2=this._flyGrowToAddAttValueDic[1];
            var loc3=[];
            var loc4="";
            var loc5=0;
            while (loc5 < 5) 
            {
                loc4 = loc2["attribute" + (loc5 + 1)];
                loc3 = loc3.concat(CutDataUtil.getStringWithoutSharp(loc4));
                ++loc5;
            }
            var loc6=[];
            var loc7=[];
            var loc9=0;
            while (loc9 < loc3.length) 
            {
                if ((loc8 = parseInt(loc3[loc9])) == 9 || loc8 == 13) 
                {
                    loc7.push(loc8);
                }
                else if (loc8 == 8 || loc8 == 12) 
                {
                    loc6.push(loc8);
                }
                else 
                {
                    loc7.push(loc8);
                    loc6.push(loc8);
                }
                ++loc9;
            }
            if (CareerUtil.isPhysicalCareer(arg1)) 
            {
                return loc6;
            }
            if (CareerUtil.isMagicCareer(arg1)) 
            {
                return loc7;
            }
            return loc1;
        }

        public getFlyLvGrowNeddExp(arg1: int): int
        {
            return this._flyGrowToNeedExpDic[arg1];
        }

        public getFlyGrowLvLimit(arg1: int): int
        {
            return this._flyLvToGrowLvLimitDic[arg1];
        }

        public getFlyGrowToAddAttValue(arg1: int): TFlyGrowCulture
        {
            return this._flyGrowToAddAttValueDic[arg1] as TFlyGrowCulture;
        }

        /* internal  */writeObjExp(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                loc2 = new Map<any, any> /* flash.utils.Dictionary */();
                loc2["3"] = loc3.power;
                loc2["4"] = loc3.agile;
                loc2["5"] = loc3.habitus;
                loc2["6"] = loc3.brains;
                loc2["7"] = loc3.spiritual;
                loc2["8"] = loc3.attack;
                loc2["9"] = loc3.attack;
                loc2["12"] = loc3.crit;
                loc2["13"] = loc3.crit;
                loc2["10"] = loc3.physicalDefense;
                loc2["11"] = loc3.magicDefense;
                loc2["1"] = loc3.life;
                loc2["14"] = loc3.hit;
                loc2["15"] = loc3.jouk;
                loc2["16"] = loc3.pass;
                loc2["19"] = loc3.toughness;
                loc2["20"] = loc3.relief;
                this._fashionJewelAttriByLvDic[loc3.level] = loc2;
                this._fashionJewelExpDic[loc3.level] = loc3.exp;
                var loc6;
                var loc7=((loc6 = this)._fashionJewelMaxLv + 1);
                loc6._fashionJewelMaxLv = loc7;
            }
            return;
        }

        /* internal  */writeObjPos(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                loc1 = [];
                loc1.push(loc3.pos1, loc3.pos2, loc3.pos3, loc3.pos4, loc3.pos5, loc3.pos6);
                loc2 = loc3.fashionType + "_" + loc3.carrerType;
                this._fashionJewelPosDic[loc2] = loc1;
            }
            return;
        }

        /* internal  */writeObjValue(arg1: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg1;
            for(loc1 of loc3) 
            {
                this._fashionJewelValueDic[loc1.code] = loc1.value;
            }
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                loc1 = new WardrobeInfo();
                loc1.itemCode = loc3.itemCode;
                loc1.type = loc3.type;
                if (loc1.type != WardrobeType.WardrobeFashion) 
                {
                    if (loc1.type != WardrobeType.WardrobeWing) 
                    {
                        if (loc1.type != WardrobeType.WardrobeFashionWeapon) 
                        {
                            if (loc1.type != WardrobeType.WardrobeFootPrint) 
                            {
                                if (loc1.type != WardrobeType.WardrobeBubble) 
                                {
                                    if (loc1.type != WardrobeType.WardrobeSurroung) 
                                    {
                                        if (loc1.type != WardrobeType.WardrobeWaistBelt) 
                                        {
                                            if (loc1.type == WardrobeType.WardrobeElf) 
                                            {
                                                this._elfArr.push(loc1.itemCode);
                                                this._elfArr.sortOn(Array.NUMERIC);
                                            }
                                        }
                                        else 
                                        {
                                            this._waistBeltArr.push(loc1.itemCode);
                                            this._waistBeltArr.sortOn(Array.NUMERIC);
                                        }
                                    }
                                    else 
                                    {
                                        this._surroundArr.push(loc1.itemCode);
                                        this._surroundArr.sortOn(Array.NUMERIC);
                                    }
                                }
                                else 
                                {
                                    this._posBubbleArr.push(loc1.itemCode);
                                    this._posBubbleArr.sortOn(Array.NUMERIC);
                                }
                            }
                            else 
                            {
                                this._footPrintArr.push(loc1.itemCode);
                                this._footPrintArr.sortOn(Array.NUMERIC);
                            }
                        }
                        else 
                        {
                            this._fashionWeaponArr.push(loc1.itemCode);
                            this._fashionWeaponArr.sortOn(Array.NUMERIC);
                        }
                    }
                    else 
                    {
                        this._wingArr.push(loc1.itemCode);
                        this._wingArr.sortOn(Array.NUMERIC);
                    }
                }
                else 
                {
                    this._fashionArr.push(loc1.itemCode);
                    this._fashionArr.sortOn(Array.NUMERIC);
                }
                loc2 = ItemConfig.instance.getInfoByCode(loc1.itemCode);
                if (!this._modelIdMap[loc2.modelId]) 
                {
                    this._modelIdMap[loc2.modelId] = new WardrobeConfigInfo();
                }
                (this._modelIdMap[loc2.modelId] as WardrobeConfigInfo).addItem(loc2);
            }
            return;
        }

        public getNameByModelId(arg1: string): string
        {
            if (this._modelIdMap[arg1]) 
            {
                return (this._modelIdMap[arg1] as WardrobeConfigInfo).name;
            }
            return "";
        }

        public getCodeByModelId(arg1: string): int
        {
            if (this._modelIdMap[arg1]) 
            {
                return (this._modelIdMap[arg1] as WardrobeConfigInfo).itemCode;
            }
            return 0;
        }

        public getItemCodesByType(arg1: int): Array<any>
        {
            if (arg1 == WardrobeType.WardrobeFashion) 
            {
                return this._fashionArr;
            }
            if (arg1 == WardrobeType.WardrobeWing) 
            {
                return this._wingArr;
            }
            if (arg1 == WardrobeType.WardrobeFashionWeapon) 
            {
                return this._fashionWeaponArr;
            }
            if (arg1 == WardrobeType.WardrobeFootPrint) 
            {
                return this._footPrintArr;
            }
            if (arg1 == WardrobeType.WardrobeBubble) 
            {
                return this._posBubbleArr;
            }
            if (arg1 == WardrobeType.WardrobeSurroung) 
            {
                return this._surroundArr;
            }
            if (arg1 == WardrobeType.WardrobeWaistBelt) 
            {
                return this._waistBeltArr;
            }
            if (arg1 == WardrobeType.WardrobeElf) 
            {
                return this._elfArr;
            }
            return [];
        }

        public getFashionWeaponItemCodesByCareer(arg1: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            while (loc3 < this._fashionWeaponArr.length) 
            {
                loc2 = new ItemData(this._fashionWeaponArr[loc3]);
                if (loc2 && loc2.itemInfo.item.career & arg1) 
                {
                    loc1.push(this._fashionWeaponArr[loc3]);
                }
                ++loc3;
            }
            return loc1;
        }

        public getfashionJewelExpDic(arg1: int): int
        {
            if (this._fashionJewelExpDic[arg1]) 
            {
                return this._fashionJewelExpDic[arg1];
            }
            return 0;
        }

        public WardrobeConfig.get fashionJewelMaxLv(): int
        {
            return this._fashionJewelMaxLv;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_wardrobe_config.json");
            this.write(loc1);
            var loc2=ConfigManager.instance.getJSONByFileName("t_fashion_jewel_exp.json");
            this.writeObjExp(loc2);
            var loc3=ConfigManager.instance.getJSONByFileName("t_fashion_jewel_pos.json");
            this.writeObjPos(loc3);
            var loc4=ConfigManager.instance.getJSONByFileName("t_fashion_jewel_value.json");
            this.writeObjValue(loc4);
            var loc5=ConfigManager.instance.getJSONByFileName("t_fly_exp_upgrade.json");
            this.writeObjFlyLv(loc5);
            var loc6=ConfigManager.instance.getJSONByFileName("t_fly_grow_culture.json");
            this.writeObjFlyGrow(loc6);
            return;
        }

        public getfashionJewelPosDic(arg1: int, arg2: int): Array<any>
        {
            var loc1=0;
            if (CareerUtil.isNewPlayerOrNoCareer(arg2)) 
            {
                return [];
            }
            if (CareerUtil.isPhysicalCareer(arg2)) 
            {
                loc1 = 51;
            }
            else 
            {
                loc1 = 204;
            }
            var loc2=arg1 + "_" + loc1;
            if (this._fashionJewelPosDic[loc2]) 
            {
                return this._fashionJewelPosDic[loc2];
            }
            return [];
        }

        public getfashionJewelValueDic(arg1: int): int
        {
            var loc1=null;
            if (this._fashionJewelValueDic[arg1]) 
            {
                return this._fashionJewelValueDic[arg1];
            }
            loc1 = ItemConfig.instance.getInfoByCode(arg1);
            if (loc1 && this._fashionJewelValueDic[loc1.item.codeUnbind]) 
            {
                return this._fashionJewelValueDic[loc1.item.codeUnbind];
            }
            return 0;
        }

        public static get instance(): WardrobeConfig
        {
            if (WardrobeConfig._instance == null) 
            {
                WardrobeConfig._instance = new WardrobeConfig();
            }
            return WardrobeConfig._instance;
        }

        /* internal  */writeObjFlyLv(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                loc1 = new TFlyExpUpgrade();
                loc1.flyLevel = loc3.flyLevel;
                loc1.needExp = loc3.needExp;
                loc1.growLevelLimit = loc3.growLevelLimit;
                this._flyLvToNeedExpDic[loc1.flyLevel] = loc1.needExp;
                this._flyLvToGrowLvLimitDic[loc1.flyLevel] = loc1.growLevelLimit;
                if (!(this._maxFlyLv <= loc1.flyLevel)) 
                {
                    continue;
                }
                this._maxFlyLv = loc1.flyLevel;
            }
            return;
        }

        public getfashionJewelAttriByLvDic(arg1: int, arg2: int): int
        {
            var loc1=arg2.toString();
            if (this._fashionJewelAttriByLvDic[arg1] && this._fashionJewelAttriByLvDic[arg1][loc1]) 
            {
                return this._fashionJewelAttriByLvDic[arg1][loc1];
            }
            return 0;
        }

        public getMaxFlyLv(): int
        {
            return this._maxFlyLv;
        }

        /* internal */ /* var */_fashionArr: Array<any>;

        /* internal */ /* var */_wingArr: Array<any>;

        /* internal */ /* var */_fashionWeaponArr: Array<any>;

        /* internal */ /* var */_footPrintArr: Array<any>;

        /* internal */ /* var */_surroundArr: Array<any>;

        /* internal */ /* var */_waistBeltArr: Array<any>;

        /* internal */ /* var */_elfArr: Array<any>;

        /* internal */ /* var */_suitArr: Array<any>;

        /* internal */ /* var */_modelIdMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_fashionJewelMaxLv: int;

        /* internal */ /* var */_fashionJewelAttriByLvDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_fashionJewelExpDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_fashionJewelPosDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_fashionJewelValueDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_maxFlyLv: int;

        /* internal */ /* var */_flyLvToNeedExpDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_flyLvToGrowLvLimitDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_flyGrowToAddAttValueDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_posBubbleArr: Array<any>;

        /* internal */ static /* var */_instance: WardrobeConfig;

        /* internal */ /* var */_flyGrowToNeedExpDic: Map<any, any> /* flash.utils.Dictionary */;
    }
